Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from mouyase/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mouyase authored Oct 31, 2019
2 parents 8e2f5d9 + 9b637fb commit a39f048
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 190 deletions.
28 changes: 15 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ android {
compileSdkVersion 29
defaultConfig {
applicationId "tech.yojigen.pivisionm"
minSdkVersion 19
minSdkVersion 21
targetSdkVersion 29
versionCode 443003
versionName '4.4.3(443003)'
versionCode 443004
versionName '4.4.3(443004)'
vectorDrawables.useSupportLibrary = true
multiDexEnabled = true
}

dexOptions {
preDexLibraries = false
}
signingConfigs {
releaseConfig {
def keystoreProperties = new Properties()
Expand Down Expand Up @@ -87,13 +89,13 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}

apply plugin: 'bugly'

bugly {
def buglyProperties = new Properties()
def buglyPropertiesFile = project.rootProject.file("bugly.properties")
buglyProperties.load(new FileInputStream(buglyPropertiesFile))
//apply plugin: 'bugly'

appId = buglyProperties['APP_ID']
appKey = buglyProperties['APP_KEY']
}
//bugly {
// def buglyProperties = new Properties()
// def buglyPropertiesFile = project.rootProject.file("bugly.properties")
// buglyProperties.load(new FileInputStream(buglyPropertiesFile))
//
// appId = buglyProperties['APP_ID']
// appKey = buglyProperties['APP_KEY']
//}
25 changes: 11 additions & 14 deletions app/src/main/java/com/reiya/pixiv/adapter/ImageAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,18 @@ public ImageAdapter(Context context) {

public ImageAdapter(Context context, List<Work> works) {
super(context, new int[]{R.layout.item_image, R.layout.item_header}, works);
setOnItemClickListener(new BaseAdapter.OnItemClickListener() {
@Override
public void onClick(Object item, List list, int position) {
if (mHasHeader && position == 0) {
Intent intent = new Intent(mContext, RankingActivity.class);
mContext.startActivity(intent);
} else {
Intent intent = new Intent(mContext, ViewActivity.class);
intent.putExtra("id", ((Work) item).getId());
TempData.put("works", list);
intent.putExtra("position", position);
mContext.startActivity(intent);
}

setOnItemClickListener((item, list, position) -> {
if (mHasHeader && position == 0) {
Intent intent = new Intent(mContext, RankingActivity.class);
mContext.startActivity(intent);
} else {
Intent intent = new Intent(mContext, ViewActivity.class);
intent.putExtra("id", ((Work) item).getId());
TempData.put("works", list);
intent.putExtra("position", position);
mContext.startActivity(intent);
}

});

setStyle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
type = "作品ID";
break;
case 2:
type = "画师IDm";
type = "画师ID";
break;
case -1:
type = "清除搜索历史";
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/reiya/pixiv/base/BaseApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public static BaseApplication getInstance() {
return sInstance;
}

@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
}

public static long getTime(String name) {
return sInstance.getSharedPreferences(name, MODE_PRIVATE).getLong("time", 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,27 @@ protected void onCreate(Bundle savedInstanceState) {
date = Calendar.getInstance();
date.set(Calendar.DAY_OF_YEAR, date.get(Calendar.DAY_OF_YEAR) - 1);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24px);
getSupportActionBar().setTitle("");
tv = (TextView) toolbar.findViewById(R.id.title);
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showDialog();
}
});
tv = toolbar.findViewById(R.id.title);
tv.setOnClickListener(v -> showDialog());

viewPager = (ViewPager) findViewById(R.id.viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
viewPager = findViewById(R.id.viewPager);
tabLayout = findViewById(R.id.tabLayout);

showDialog();
}

private void showDialog() {
new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
date.set(year, monthOfYear, dayOfMonth);
String str = StringHelper.getFormattedDate(year, monthOfYear, dayOfMonth, "-");
tv.setText(str);
viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), getApplicationContext(), str));
tabLayout.setupWithViewPager(viewPager);
}
new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
date.set(year, monthOfYear, dayOfMonth);
String str = StringHelper.getFormattedDate(year, monthOfYear, dayOfMonth, "-");
tv.setText(str);
viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), getApplicationContext(), str));
tabLayout.setupWithViewPager(viewPager);
}, date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH)).show();
}

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/reiya/pixiv/network/HttpClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ public static void init(Context context) {
int connectMode = Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString(context.getString(R.string.key_connect_mode), "0"));
switch (connectMode) {
case 0:
builder.sslSocketFactory(PixivSSLSocketFactory.getInstance(), PixivTrustManager.getInstance())
.dns(PixivDNS.getInstance());
builder.sslSocketFactory(PixivSSLSocketFactory.getInstance(), PixivTrustManager.getInstance()).dns(PixivDNS.getInstance());
break;
case 1:
break;
Expand Down
28 changes: 17 additions & 11 deletions app/src/main/java/com/reiya/pixiv/ranking/RankingActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.fragment.app.FragmentTransaction;
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.tabs.TabLayout;
Expand All @@ -36,13 +37,13 @@ protected void onCreate(Bundle savedInstanceState) {
setTheme(Theme.getTheme());
setContentView(R.layout.activity_ranking);

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_arrow_back_white_24px);

viewPager = (ViewPager) findViewById(R.id.viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabLayout);
viewPager = findViewById(R.id.viewPager);
tabLayout = findViewById(R.id.tabLayout);

mFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), UserData.getSpecialMode() ? 1 : 0);
viewPager.setAdapter(mFragmentPagerAdapter);
Expand All @@ -65,14 +66,13 @@ public boolean onOptionsItemSelected(MenuItem item) {
finish();
break;
case 0:
new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
mDate.set(year, monthOfYear, dayOfMonth);
String str = StringHelper.getFormattedDate(year, monthOfYear, dayOfMonth, "-");
viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), UserData.getSpecialMode() ? 1 : 0, str));
tabLayout.setupWithViewPager(viewPager);
}
new DatePickerDialog(this, (view, year, monthOfYear, dayOfMonth) -> {
mDate.set(year, monthOfYear, dayOfMonth);
String str = StringHelper.getFormattedDate(year, monthOfYear, dayOfMonth, "-");
System.out.println(str);
viewPager.setAdapter(new MyFragmentPagerAdapter(getSupportFragmentManager(), UserData.getSpecialMode() ? 1 : 0, str));
viewPager.requestFocus();
tabLayout.setupWithViewPager(viewPager);
}, mDate.get(Calendar.YEAR), mDate.get(Calendar.MONTH), mDate.get(Calendar.DAY_OF_MONTH)).show();
break;
}
Expand Down Expand Up @@ -106,6 +106,12 @@ class MyFragmentPagerAdapter extends FragmentPagerAdapter {
}
mMode = mode;
mDate = date;
//修复日期选择不可用
FragmentTransaction fragmentTransaction = fm.beginTransaction();
for (Fragment fragment : fm.getFragments()) {
fragmentTransaction.remove(fragment);
}
fragmentTransaction.commitNow();
}

MyFragmentPagerAdapter(FragmentManager fm, int mode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (layoutManager instanceof LinearLayoutManager) {
lastVisibleItem = ((LinearLayoutManager) getLayoutManager()).findLastVisibleItemPosition() + 1;
} else {
lastVisibleItem = ((StaggeredGridLayoutManager) getLayoutManager()).findLastVisibleItemPositions(null)[0] + ((StaggeredGridLayoutManager) getLayoutManager()).getSpanCount();
int[] lastPositions = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()];
lastVisibleItem = ((StaggeredGridLayoutManager) getLayoutManager()).findLastVisibleItemPositions(lastPositions)[0] + ((StaggeredGridLayoutManager) getLayoutManager()).getSpanCount();
}
}
});
Expand Down
Loading

0 comments on commit a39f048

Please sign in to comment.