diff --git a/app/build.gradle b/app/build.gradle index 9132c90..7ca0cb7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -187,8 +187,6 @@ dependencies { implementation 'com.jaeger.statusbarutil:library:1.5.0' /* VasDolly渠道包渠道获取帮助类 */ api 'com.leon.channel:helper:2.0.3' - /* 图片浏览器所需 */ - implementation 'com.github.chrisbanes:PhotoView:2.0.0' /*-----------------------------------------*/ diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/CitysActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/CitysActivity.java deleted file mode 100644 index 13a9225..0000000 --- a/app/src/main/java/com/maning/gankmm/ui/activity/CitysActivity.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.maning.gankmm.ui.activity; - -import android.content.Intent; -import android.os.Bundle; -import android.support.v7.widget.DefaultItemAnimator; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; -import android.view.View; - -import com.maning.gankmm.R; -import com.maning.gankmm.bean.mob.CitysEntity; -import com.maning.gankmm.skin.SkinManager; -import com.maning.gankmm.ui.adapter.RecycleCitysAdapter; -import com.maning.gankmm.ui.base.BaseActivity; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import butterknife.Bind; -import butterknife.ButterKnife; - -@Deprecated -public class CitysActivity extends BaseActivity { - - @Bind(R.id.toolbar) - Toolbar toolbar; - @Bind(R.id.recycle_province) - RecyclerView recycleProvince; - @Bind(R.id.recycle_city) - RecyclerView recycleCity; - - - private List provinceList = new ArrayList<>(); - private List citysList = new ArrayList<>(); - private Map> citysMap = new HashMap<>(); - private RecycleCitysAdapter recycleCitysAdapter_province; - private RecycleCitysAdapter recycleCitysAdapter_city; - private String chooseProvinceName; - private String chooseCityName; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_citys); - ButterKnife.bind(this); - - initMyToolBar(); - - initViews(); - - initAdapter(); - - } - - private void initAdapter() { - //获取数据 - CitysEntity citysCache = null; - if (citysCache != null) { - List cityList = citysCache.getResult(); - for (int i = 0; i < cityList.size(); i++) { - String province = cityList.get(i).getProvince(); - provinceList.add(province); - List citysNameList = new ArrayList<>(); - List city = cityList.get(i).getCity(); - if (city != null) { - for (int j = 0; j < city.size(); j++) { - String cityName = city.get(j).getCity(); - citysNameList.add(cityName); - } - citysMap.put(province, citysNameList); - } - } - recycleCitysAdapter_province = new RecycleCitysAdapter(this, provinceList, 0); - recycleProvince.setAdapter(recycleCitysAdapter_province); - //点击事件 - recycleCitysAdapter_province.setOnItemClickLitener(new RecycleCitysAdapter.OnItemClickLitener() { - @Override - public void onItemClick(View view, int position) { - chooseProvinceName = provinceList.get(position); - citysList = citysMap.get(chooseProvinceName); - //刷新第二个列表 - if (recycleCitysAdapter_city != null) { - recycleCitysAdapter_city.updateDatas(citysList); - } else { - recycleCitysAdapter_city = new RecycleCitysAdapter(CitysActivity.this, citysList, 1); - recycleCity.setAdapter(recycleCitysAdapter_city); - //点击事件 - recycleCitysAdapter_city.setOnItemClickLitener(new RecycleCitysAdapter.OnItemClickLitener() { - @Override - public void onItemClick(View view, int position) { - chooseCityName = recycleCitysAdapter_city.getPositionValue(position); - //关闭界面 - Intent intent = new Intent(); - intent.putExtra("provinceName", chooseProvinceName); - intent.putExtra("cityName", chooseCityName); - setResult(100, intent); - finish(); - } - }); - } - } - }); - - } - - } - - private void initViews() { - - LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); - recycleProvince.setLayoutManager(linearLayoutManager); - recycleProvince.setItemAnimator(new DefaultItemAnimator()); - - - LinearLayoutManager linearLayoutManager2 = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false); - recycleCity.setLayoutManager(linearLayoutManager2); - recycleCity.setItemAnimator(new DefaultItemAnimator()); - - } - - - private void initMyToolBar() { - initBackToolBar(toolbar, "城市选择"); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - this.finish(); - break; - } - return super.onOptionsItemSelected(item); - } -} diff --git a/app/src/main/java/com/maning/gankmm/ui/activity/ImagesActivity.java b/app/src/main/java/com/maning/gankmm/ui/activity/ImagesActivity.java deleted file mode 100644 index 9be3404..0000000 --- a/app/src/main/java/com/maning/gankmm/ui/activity/ImagesActivity.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.maning.gankmm.ui.activity; - -import android.content.Context; -import android.content.Intent; -import android.graphics.Bitmap; -import android.os.Bundle; -import android.support.v4.view.ViewPager; -import android.support.v7.widget.Toolbar; -import android.view.MenuItem; -import android.widget.TextView; - -import com.maning.gankmm.R; -import com.maning.gankmm.skin.SkinManager; -import com.maning.gankmm.ui.adapter.ImagesAdapter; -import com.maning.gankmm.ui.base.BaseActivity; -import com.maning.gankmm.ui.iView.IImageView; -import com.maning.gankmm.ui.presenter.impl.ImagePresenterImpl; -import com.maning.gankmm.utils.IntentUtils; -import com.maning.gankmm.utils.PermissionUtils; - -import java.util.ArrayList; - -import butterknife.Bind; -import butterknife.ButterKnife; -import io.github.yavski.fabspeeddial.FabSpeedDial; -import io.github.yavski.fabspeeddial.SimpleMenuListenerAdapter; - -public class ImagesActivity extends BaseActivity implements IImageView { - - private static final String TAG = ImagesActivity.class.getSimpleName(); - @Bind(R.id.viewPager) - ViewPager viewPager; - @Bind(R.id.tv_showNum) - TextView tvShowNum; - @Bind(R.id.toolbar) - Toolbar toolbar; - @Bind(R.id.fab_speed_dial) - FabSpeedDial fabSpeedDial; - - private Context mContext; - - private ArrayList mDatas = new ArrayList<>(); - private int startIndex; - private ImagesAdapter imageAdapter; - - private ImagePresenterImpl imagePresenter; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_big_image); - ButterKnife.bind(this); - mContext = this; - - initMyToolBar(); - - imagePresenter = new ImagePresenterImpl(this, this); - - initIntent(); - - tvShowNum.setText(String.valueOf((startIndex + 1) + "/" + mDatas.size())); - - //初始化ViewPager - initViewPager(); - - initMenuListener(); - - } - - private void initMenuListener() { - fabSpeedDial.setMenuListener(new SimpleMenuListenerAdapter() { - @Override - public boolean onMenuItemSelected(MenuItem menuItem) { - switch (menuItem.getItemId()) { - case R.id.action_save: - PermissionUtils.checkWritePermission(mContext, new PermissionUtils.PermissionCallBack() { - @Override - public void onGranted() { - imagePresenter.saveImage(); - } - - @Override - public void onDenied() { - showProgressError("获取存储权限失败,请前往设置页面打开存储权限"); - } - }); - - break; - case R.id.action_share: - int currentItem = viewPager.getCurrentItem(); - String picUrl = mDatas.get(currentItem); - IntentUtils.startAppShareText(ImagesActivity.this, "GankMM图片分享", "分享图片:" + picUrl); - break; - case R.id.action_wallpaper: - imagePresenter.setWallpaper(); - break; - } - return false; - } - }); - } - - private void initMyToolBar() { - int currentSkinType = SkinManager.getCurrentSkinType(this); - if (SkinManager.THEME_DAY == currentSkinType) { - initToolBar(toolbar, getString(R.string.gank_page_title_girls), R.drawable.gank_ic_back_white); - } else { - initToolBar(toolbar, getString(R.string.gank_page_title_girls), R.drawable.gank_ic_back_night); - } - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - this.finish(); - return true; - } - return super.onOptionsItemSelected(item); - } - - private void initViewPager() { - imageAdapter = new ImagesAdapter(mContext, mDatas); - viewPager.setAdapter(imageAdapter); - if (startIndex > 0) { - viewPager.setCurrentItem(startIndex); - } - viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { - @Override - public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { - - } - - @Override - public void onPageSelected(int position) { - tvShowNum.setText(String.valueOf((position + 1) + "/" + mDatas.size())); - } - - @Override - public void onPageScrollStateChanged(int state) { - - } - }); - } - - private void initIntent() { - //获取传递的数据 - Intent intent = getIntent(); - mDatas = intent.getStringArrayListExtra(IntentUtils.ImageArrayList); - startIndex = intent.getIntExtra(IntentUtils.ImagePositionForImageShow, 0); - } - - - @Override - public void showBaseProgressDialog(String msg) { - showProgressDialog(msg); - } - - @Override - public void hideBaseProgressDialog() { - dissmissProgressDialog(); - } - - @Override - public void showBasesProgressSuccess(String msg) { - showProgressSuccess(msg); - } - - @Override - public void showBasesProgressError(String msg) { - showProgressError(msg); - } - - @Override - public Bitmap getCurrentImageViewBitmap() { - return imageAdapter.getCurrentImageViewBitmap(); - } - - @Override - protected void onDestroy() { - //清空集合 - if (mDatas != null) { - mDatas.clear(); - mDatas = null; - } - imagePresenter.detachView(); - super.onDestroy(); - } - -} diff --git a/app/src/main/java/com/maning/gankmm/ui/adapter/ImagesAdapter.java b/app/src/main/java/com/maning/gankmm/ui/adapter/ImagesAdapter.java deleted file mode 100644 index 9082d4c..0000000 --- a/app/src/main/java/com/maning/gankmm/ui/adapter/ImagesAdapter.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.maning.gankmm.ui.adapter; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.drawable.Drawable; -import android.support.annotation.Nullable; -import android.support.v4.view.PagerAdapter; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; - -import com.bumptech.glide.Glide; -import com.bumptech.glide.load.DataSource; -import com.bumptech.glide.load.engine.GlideException; -import com.bumptech.glide.request.RequestListener; -import com.bumptech.glide.request.target.Target; -import com.maning.gankmm.R; -import com.maning.gankmm.ui.view.PinchImageView; -import com.maning.gankmm.ui.view.ProgressWheel; - -import java.util.ArrayList; - -/** - * Created by maning on 16/6/21. - * 图片浏览 - */ -public class ImagesAdapter extends PagerAdapter { - - private Context mContext; - private ArrayList mDatas; - private LayoutInflater layoutInflater; - private View mCurrentView; - - public ImagesAdapter(Context mContext, ArrayList mDatas) { - this.mContext = mContext; - this.mDatas = mDatas; - layoutInflater = LayoutInflater.from(this.mContext); - } - - @Override - public int getCount() { - return mDatas.size(); - } - - @Override - public void setPrimaryItem(ViewGroup container, int position, Object object) { - super.setPrimaryItem(container, position, object); - mCurrentView = (View) object; - } - - public View getPrimaryItem() { - return mCurrentView; - } - - @Override - public View instantiateItem(ViewGroup container, int position) { - final String imageUrl = mDatas.get(position); - View inflate = layoutInflater.inflate(R.layout.item_show_image, container, false); - final ImageView imageView = (ImageView) inflate.findViewById(R.id.imageView); - final ProgressWheel progressbar = (ProgressWheel) inflate.findViewById(R.id.progressbar); - Glide - .with(mContext) - .load(imageUrl) - .thumbnail(0.2f) - .listener(new RequestListener() { - @Override - public boolean onLoadFailed(@Nullable GlideException e, Object model, Target target, boolean isFirstResource) { - progressbar.setVisibility(View.GONE); - return false; - } - - @Override - public boolean onResourceReady(Drawable resource, Object model, Target target, DataSource dataSource, boolean isFirstResource) { - progressbar.setVisibility(View.GONE); - return false; - } - }) - .into(imageView); - container.addView(inflate); - - return inflate; - } - - @Override - public void destroyItem(ViewGroup container, int position, Object object) { - container.removeView((View) object); - } - - @Override - public boolean isViewFromObject(View view, Object object) { - return view == object; - } - - public Bitmap getCurrentImageViewBitmap() { - View currentItem = getPrimaryItem(); - if (currentItem == null) { - return null; - } - PinchImageView imageView = (PinchImageView) currentItem.findViewById(R.id.imageView); - if (imageView == null) { - return null; - } - imageView.setDrawingCacheEnabled(true); - Bitmap bitmap = Bitmap.createBitmap(imageView.getDrawingCache()); - imageView.setDrawingCacheEnabled(false); - return bitmap; - } -} diff --git a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleCitysAdapter.java b/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleCitysAdapter.java deleted file mode 100644 index 2de6d2b..0000000 --- a/app/src/main/java/com/maning/gankmm/ui/adapter/RecycleCitysAdapter.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.maning.gankmm.ui.adapter; - -import android.content.Context; -import android.support.v7.widget.RecyclerView; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import com.maning.gankmm.R; -import com.maning.gankmm.skin.SkinManager; - -import java.util.List; - -import butterknife.Bind; -import butterknife.ButterKnife; - -/** - * Created by maning on 16/5/17. - */ -public class RecycleCitysAdapter extends RecyclerView.Adapter { - - private Context context; - private List mDatas; - private LayoutInflater layoutInflater; - private int currentPosition = -1; - //标记:0-左边,1:右边 - private int flag = 0; - - public RecycleCitysAdapter(Context context, List mDatas, int flag) { - this.context = context; - this.flag = flag; - this.mDatas = mDatas; - layoutInflater = LayoutInflater.from(this.context); - } - - public void updateDatas(List mDatas) { - this.mDatas = mDatas; - notifyDataSetChanged(); - } - - private OnItemClickLitener mOnItemClickLitener; - - public void setOnItemClickLitener(OnItemClickLitener mOnItemClickLitener) { - this.mOnItemClickLitener = mOnItemClickLitener; - } - - @Override - public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - - View inflate = layoutInflater.inflate(R.layout.item_city_choose, parent, false); - - return new MyViewHolder(inflate); - } - - @Override - public void onBindViewHolder(final MyViewHolder viewHolder, final int position) { - - viewHolder.tv_title.setText(mDatas.get(position)); - - //如果设置了回调,则设置点击事件 - if (mOnItemClickLitener != null) { - viewHolder.itemView.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - currentPosition = position; - mOnItemClickLitener.onItemClick(viewHolder.itemView, position); - notifyDataSetChanged(); - } - }); - } - - if (flag == 0) { - viewHolder.tv_title.setTextColor(context.getResources().getColor(R.color.black_text2_color)); - viewHolder.item_bg.setBackgroundResource(R.color.itemGrayBg); - viewHolder.line.setVisibility(View.GONE); - if (currentPosition == position) { - viewHolder.tv_title.setTextColor(context.getResources().getColor(R.color.main_color)); - viewHolder.item_bg.setBackgroundResource(R.color.white); - viewHolder.line.setVisibility(View.VISIBLE); - } - } else { - viewHolder.item_bg.setBackgroundResource(R.color.white); - viewHolder.line.setVisibility(View.GONE); - } - - } - - public String getPositionValue(int position) { - return mDatas.get(position); - } - - @Override - public int getItemCount() { - return mDatas.size(); - } - - class MyViewHolder extends RecyclerView.ViewHolder { - - @Bind(R.id.tv_title) - TextView tv_title; - @Bind(R.id.line) - TextView line; - @Bind(R.id.item_bg) - RelativeLayout item_bg; - - - public MyViewHolder(View itemView) { - super(itemView); - ButterKnife.bind(this, itemView); - } - } - - public interface OnItemClickLitener { - void onItemClick(View view, int position); - } -} diff --git a/app/src/main/res/layout/activity_big_image.xml b/app/src/main/res/layout/activity_big_image.xml deleted file mode 100644 index 04d8e2f..0000000 --- a/app/src/main/res/layout/activity_big_image.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_citys.xml b/app/src/main/res/layout/activity_citys.xml deleted file mode 100644 index 2329fbe..0000000 --- a/app/src/main/res/layout/activity_citys.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/item_city_choose.xml b/app/src/main/res/layout/item_city_choose.xml deleted file mode 100644 index d7a7b40..0000000 --- a/app/src/main/res/layout/item_city_choose.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - -