181
182
            }
183
        }
184
185
        @Override
186
        public void onProgress(int progress, long progressTime) {
187
            final VideoCompressionActivity mHomeFragment = mWeakReference.get();
188
            if (mHomeFragment != null) {
189
                //progressTime 可以在结合视频总时长去计算合适的进度值
190
                Log.e("TAG", "onProgress progress:"+progress+"  progressTime:"+progressTime);
191
            }
192
        }
193
194
        @Override
195
        public void onCancel() {
196
            final VideoCompressionActivity mHomeFragment = mWeakReference.get();
197
            if (mHomeFragment != null) {
198
                Log.e("TAG", "已取消");
199
200
            }
201
        }
202
203
        @Override
204
        public void onError(String message) {
205
            final VideoCompressionActivity mHomeFragment = mWeakReference.get();
206
            if (mHomeFragment != null) {
207
                Log.e("TAG", "出错了 onError:" + message);
208
            }
209
        }
210
    }
211
212
    @Override
213
    public void onDestroy() {
214
        super.onDestroy();
215
        if (myRxFFmpegSubscriber != null) {
216
            myRxFFmpegSubscriber.dispose();
217
        }
218
    }
219
220
    public String getFileExtension(String path) {
221
        String extension = "";
222
        File file = new File(path);
223
        try {
224
            if (file != null && file.exists()) {
225
                String name = file.getName();
226
                extension = name.substring(name.lastIndexOf("."));
227
            }
228
        } catch (Exception e) {
229
            extension = "";
230
        }
231
        return extension;
232
    }
233
234
    public static String GetFileSize(String path){
235
        String size = "";
236
        File file = new File(path);
237
        if(file.exists() && file.isFile()){
238
            long fileS = file.length();
239
            DecimalFormat df = new DecimalFormat("#.00");
240
            if (fileS < 1024) {
241
                size = df.format((double) fileS) + "BT";
242
            } else if (fileS < 1048576) {
243
                size = df.format((double) fileS / 1024) + "KB";
244
            } else if (fileS < 1073741824) {
245
                size = df.format((double) fileS / 1048576) + "MB";
246
            } else {
247
                size = df.format((double) fileS / 1073741824) +"GB";
248
            }
249
        }else if(file.exists() && file.isDirectory()){
250
            size = "";
251
        }else{
252
            size = "0BT";
253
        }
254
        return size;
255
    }
256
}

+ 86 - 0
app/src/main/java/com/electric/chargingpile/adapter/QuarterAdapter.java

@ -0,0 +1,86 @@
1
package com.electric.chargingpile.adapter;
2
3
import android.content.Context;
4
import android.graphics.Color;
5
import android.view.LayoutInflater;
6
import android.view.View;
7
import android.view.ViewGroup;
8
import android.widget.TextView;
9
10
import androidx.annotation.NonNull;
11
import androidx.recyclerview.widget.RecyclerView;
12
13
import com.electric.chargingpile.R;
14
15
import org.jetbrains.annotations.NotNull;
16
17
import java.util.ArrayList;
18
19
public class QuarterAdapter extends RecyclerView.Adapter<QuarterAdapter.ViewHolder> {
20
    private Context mContext=null;
21
22
    private int mSelectPostion=0;
23
24
    private ArrayList<String> mDatas= new ArrayList<>();
25
    private ItemOnClick mItemOnClick= null;
26
27
    public QuarterAdapter(Context mContext) {
28
        this.mContext = mContext;
29
        mDatas.add("一季度");
30
        mDatas.add("二季度");
31
        mDatas.add("三季度");
32
        mDatas.add("四季度");
33
    }
34
35
    public ItemOnClick getItemOnClick() {
36
        return mItemOnClick;
37
    }
38
39
    public void setItemOnClick(ItemOnClick mItemOnClick) {
40
        this.mItemOnClick = mItemOnClick;
41
    }
42
43
    @NonNull
44
    @NotNull
45
    @Override
46
    public ViewHolder onCreateViewHolder(@NonNull @NotNull ViewGroup parent, int viewType) {
47
        View rootView = LayoutInflater.from(mContext).inflate(R.layout.layout_text_item, parent, false);
48
        return new ViewHolder(rootView);
49
    }
50
51
    @Override
52
    public void onBindViewHolder(@NonNull @NotNull ViewHolder holder, int position) {
53
        if (mSelectPostion==position){
54
            holder.mTextView.setTextColor(Color.parseColor("#ff0e0e0e"));
55
        }else{
56
            holder.mTextView.setTextColor(Color.parseColor("#9B9B9B"));
57
        }
58
        holder.mTextView.setText(mDatas.get(position));
59
        holder.mTextView.setOnClickListener(v->{
60
            if (mItemOnClick!=null){
61
                mSelectPostion=position;
62
                mItemOnClick.onClick(position);
63
                notifyDataSetChanged();
64
            }
65
        });
66
    }
67
68
    @Override
69
    public int getItemCount() {
70
        return mDatas.size();
71
    }
72
73
    public static class ViewHolder extends RecyclerView.ViewHolder {
74
75
        private final TextView mTextView;
76
77
        public ViewHolder(@NonNull @NotNull View itemView) {
78
            super(itemView);
79
            mTextView = itemView.findViewById(R.id.textView);
80
        }
81
    }
82
83
    public interface ItemOnClick{
84
        void onClick(int posistion);
85
    }
86
}

+ 54 - 1
app/src/main/java/com/electric/chargingpile/fragment/TotalListFragment.java

@ -1,20 +1,33 @@
1 1
package com.electric.chargingpile.fragment;
2 2
3 3
import android.content.Intent;
4
import android.graphics.Color;
5
import android.graphics.drawable.ColorDrawable;
4 6
import android.os.Bundle;
7
8
import androidx.core.widget.PopupWindowCompat;
5 9
import androidx.fragment.app.Fragment;
10
import androidx.recyclerview.widget.LinearLayoutManager;
11
import androidx.recyclerview.widget.RecyclerView;
12
6 13
import android.util.Log;
14
import android.view.Gravity;
7 15
import android.view.LayoutInflater;
8 16
import android.view.View;
9 17
import android.view.ViewGroup;
10 18
import android.widget.LinearLayout;
11 19
import android.widget.ListView;
20
import android.widget.PopupWindow;
12 21
import android.widget.RelativeLayout;
13 22
import android.widget.TextView;
23
import android.widget.Toast;
14 24
25
import com.blankj.utilcode.util.SizeUtils;
26
import com.blankj.utilcode.util.Utils;
15 27
import com.electric.chargingpile.R;
16 28
import com.electric.chargingpile.activity.LoginActivity;
17 29
import com.electric.chargingpile.activity.MainMapActivity;
30
import com.electric.chargingpile.adapter.QuarterAdapter;
18 31
import com.electric.chargingpile.adapter.TotalListAdapter;
19 32
import com.electric.chargingpile.application.MainApplication;
20 33
import com.electric.chargingpile.data.MyOtto;
@ -28,6 +41,7 @@ import com.squareup.picasso.Picasso;
28 41
import com.zhy.http.okhttp.OkHttpUtils;
29 42
import com.zhy.http.okhttp.callback.StringCallback;
30 43
44
import org.jetbrains.annotations.NotNull;
31 45
import org.json.JSONArray;
32 46
import org.json.JSONException;
33 47
import org.json.JSONObject;
@ -37,13 +51,15 @@ import java.util.ArrayList;
37 51
38 52
import okhttp3.Call;
39 53
40
public class TotalListFragment extends Fragment {
54
public class TotalListFragment extends Fragment implements View.OnClickListener {
41 55
    private TextView tv_total_name, tv_total_ranking, tv_total_charge, tv_notice, tv_ranking_zanwu;
42 56
    private CircleImageView iv_icon;
43 57
    private ListView lv_total;
44 58
    private LinearLayout ll_ranking;
45 59
    private TextView tv_no_login, tv_login;
46 60
    private RelativeLayout rl_totalList;
61
    private LinearLayout layoutQuarter;
62
    private PopupWindow mPopupWindow;
47 63
48 64
    @Override
49 65
    public void onCreate(Bundle savedInstanceState) {
@ -55,6 +71,7 @@ public class TotalListFragment extends Fragment {
55 71
                             Bundle savedInstanceState) {
56 72
        View view = inflater.inflate(R.layout.fragment_total_list, null);
57 73
        initView(view);
74
        initPopupWindow();
58 75
        MyOtto.getInstance().register(this);
59 76
        getData(null);
60 77
        return view;
@ -72,6 +89,8 @@ public class TotalListFragment extends Fragment {
72 89
        tv_no_login = (TextView) v.findViewById(R.id.tv_no_login);
73 90
        tv_login = (TextView) v.findViewById(R.id.tv_login);
74 91
        rl_totalList = (RelativeLayout) v.findViewById(R.id.rl_totalList);
92
        layoutQuarter = (LinearLayout) v.findViewById(R.id.layoutQuarter);
93
        layoutQuarter.setOnClickListener(this);
75 94
    }
76 95
77 96
    @Subscribe
@ -191,4 +210,38 @@ public class TotalListFragment extends Fragment {
191 210
        super.onDestroy();
192 211
        MyOtto.getInstance().unregister(this);
193 212
    }
213
214
    @Override
215
    public void onClick(View v) {
216
        switch (v.getId()){
217
            case R.id.layoutQuarter:
218
                if (mPopupWindow!=null){
219
                    mPopupWindow.showAsDropDown(layoutQuarter,0, 0, Gravity.BOTTOM);
220
                }
221
                break;
222
        }
223
    }
224
225
    @NotNull
226
    private void initPopupWindow() {
227
        View rootView = LayoutInflater.from(requireContext()).inflate(R.layout.layout_quarter, null, false);
228
        mPopupWindow = new PopupWindow(rootView, SizeUtils.dp2px(92),ViewGroup.LayoutParams.WRAP_CONTENT);
229
        // 设置PopupWindow的背景
230
        mPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
231
        // 设置PopupWindow是否能响应外部点击事件
232
        mPopupWindow.setOutsideTouchable(true);
233
        // 设置PopupWindow是否能响应点击事件
234
        mPopupWindow.setTouchable(true);
235
236
        RecyclerView recyclerView = rootView.findViewById(R.id.recyclerView);
237
        recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
238
        QuarterAdapter adapter = new QuarterAdapter(requireContext());
239
        adapter.setItemOnClick(posistion -> {
240
            //TODO
241
            Toast.makeText(requireContext(), ""+posistion, Toast.LENGTH_SHORT).show();
242
            mPopupWindow.dismiss();
243
        });
244
245
        recyclerView.setAdapter(adapter);
246
    }
194 247
}

+ 5 - 0
app/src/main/res/drawable/bg_quarter.xml

@ -0,0 +1,5 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<shape xmlns:android="http://schemas.android.com/apk/res/android">
3
    <corners android:radius="4dp" />
4
    <solid android:color="@color/color_white" />
5
</shape>

+ 25 - 0
app/src/main/res/layout/activity_video_compression.xml

@ -0,0 +1,25 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="match_parent"
4
    android:orientation="vertical"
5
    android:layout_height="match_parent">
6
    <Button
7
        android:id="@+id/openPhoto"
8
        android:text="打开相册"
9
        android:layout_width="wrap_content"
10
        android:layout_height="wrap_content"/>
11
    <Button
12
        android:id="@+id/videoZip"
13
        android:text="压缩视频"
14
        android:layout_width="wrap_content"
15
        android:layout_height="wrap_content"/>
16
    <Button
17
        android:id="@+id/startVideoZip"
18
        android:text="播放压缩后的视频"
19
        android:layout_width="wrap_content"
20
        android:layout_height="wrap_content"/>
21
    <TextView
22
        android:id="@+id/progress"
23
        android:layout_width="wrap_content"
24
        android:layout_height="wrap_content"/>
25
</LinearLayout>

+ 28 - 0
app/src/main/res/layout/fragment_total_list.xml

@ -8,6 +8,34 @@
8 8
    tools:context="com.electric.chargingpile.fragment.MonthListFragment">
9 9
10 10
11
    <LinearLayout
12
        android:id="@+id/layoutQuarter"
13
        android:layout_marginBottom="15dp"
14
        android:layout_marginStart="12dp"
15
        android:layout_marginEnd="12dp"
16
        android:layout_marginTop="15dp"
17
        android:layout_width="wrap_content"
18
        android:layout_height="wrap_content">
19
        <TextView
20
            android:layout_width="wrap_content"
21
            android:layout_height="wrap_content"
22
            android:text="当年季度筛选"
23
            android:textColor="@color/color_green_style1"
24
            android:textSize="14sp"
25
            />
26
        <TextView
27
            android:layout_gravity="center_vertical"
28
            android:layout_marginStart="4dp"
29
            android:layout_width="wrap_content"
30
            android:layout_height="wrap_content"
31
            android:text="▼"
32
            android:textColor="@color/color_green_style1"
33
            android:textSize="8dp"
34
            />
35
36
37
    </LinearLayout>
38
11 39
    <RelativeLayout
12 40
        android:id="@+id/rl_totalList"
13 41
        android:layout_width="match_parent"

+ 10 - 0
app/src/main/res/layout/layout_quarter.xml

@ -0,0 +1,10 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="92dp"
4
    android:background="@drawable/bg_quarter"
5
    android:layout_height="wrap_content">
6
    <androidx.recyclerview.widget.RecyclerView
7
        android:id="@+id/recyclerView"
8
        android:layout_width="match_parent"
9
        android:layout_height="wrap_content"/>
10
</LinearLayout>

+ 12 - 0
app/src/main/res/layout/layout_text_item.xml

@ -0,0 +1,12 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
3
    android:layout_width="match_parent"
4
    xmlns:tools="http://schemas.android.com/tools"
5
    tools:textColor="#ff0e0e0e"
6
    android:textSize="12sp"
7
    android:id="@+id/textView"
8
    tools:text="第一季度"
9
    android:paddingTop="14dp"
10
    android:paddingBottom="14dp"
11
    android:gravity="center"
12
    android:layout_height="wrap_content" />

+ 4 - 0
app/src/main/res/values/colors.xml

@ -0,0 +1,4 @@
1
<?xml version="1.0" encoding="utf-8"?>
2
<resources>
3
    <color name="color_green_style1">#ff3ab948</color>
4
</resources>

+ 1 - 1
app/src/main/res/values/strings.xml

@ -18,7 +18,7 @@
18 18
    <string name="updated_at">上次更新于%1$s前</string>
19 19
    <string name="updated_just_now">刚刚更新</string>
20 20
    <string name="time_error">时间有问题</string>
21
    <string name="string_tab_qa">聊聊</string>
21
    <string name="string_tab_qa">社区</string>
22 22
23 23
24 24
    <string name="main_name">主界面</string>

+ 1 - 0
build.gradle

@ -12,6 +12,7 @@ buildscript {
12 12
        maven {url 'https://maven.aliyun.com/repository/google/'}
13 13
        maven {url 'https://maven.aliyun.com/repository/public/'}
14 14
        maven {url 'https://maven.aliyun.com/repository/gradle-plugin/'}
15
        maven { url "https://www.jitpack.io" }
15 16
        mavenCentral()
16 17
    }
17 18

cdzApp - Gogs: Go Git Service

充电桩app代码

huyuguo 319397b60f 配置信息优化 6 年 前
..
src 3f53132d2f 支付宝sdk更新 6 年 前
.gitignore 06bd894653 init 7 年 前
build.gradle 319397b60f 配置信息优化 6 年 前
proguard-rules.pro 06bd894653 init 7 年 前