mirror of
https://github.com/nuclearfog/Shitter.git
synced 2025-02-09 08:38:38 +01:00
bug fix
This commit is contained in:
parent
49afdcac7c
commit
f0e5c7175e
@ -102,7 +102,13 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (settingChanged) {
|
||||
timelineList.setAdapter(null);
|
||||
trendList.setAdapter(null);
|
||||
mentionList.setAdapter(null);
|
||||
}
|
||||
if (home == null || settingChanged) {
|
||||
settingChanged = false;
|
||||
home = new MainPage(this);
|
||||
home.execute(MainPage.DATA, 1);
|
||||
}
|
||||
@ -111,13 +117,13 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
if (home != null && !home.isCancelled()) {
|
||||
home.cancel(true);
|
||||
timelineReload.setRefreshing(false);
|
||||
trendReload.setRefreshing(false);
|
||||
mentionReload.setRefreshing(false);
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
||||
@ -230,19 +236,15 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
if (home != null && !home.isCancelled())
|
||||
home.cancel(true);
|
||||
home = new MainPage(MainActivity.this);
|
||||
|
||||
switch (tabIndex) {
|
||||
case 0:
|
||||
home.execute(MainPage.HOME, 1);
|
||||
break;
|
||||
case 1:
|
||||
home.execute(MainPage.TRND, 1);
|
||||
break;
|
||||
case 2:
|
||||
home.execute(MainPage.MENT, 1);
|
||||
break;
|
||||
}
|
||||
if (tabIndex == 0)
|
||||
home.execute(MainPage.HOME, 1);
|
||||
else if (tabIndex == 1)
|
||||
home.execute(MainPage.TRND, 1);
|
||||
else if (tabIndex == 2)
|
||||
home.execute(MainPage.MENT, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -311,7 +313,6 @@ public class MainActivity extends AppCompatActivity implements OnRefreshListener
|
||||
|
||||
private void animate() {
|
||||
final int ANIM_DUR = 300;
|
||||
|
||||
final int DIMENS = Animation.RELATIVE_TO_PARENT;
|
||||
final float LEFT = -1.0f;
|
||||
final float RIGHT = 1.0f;
|
||||
|
@ -59,21 +59,21 @@ public class MainPage extends AsyncTask<Integer, Integer, Integer> {
|
||||
|
||||
if (timelineAdapter == null) {
|
||||
timelineAdapter = new TimelineAdapter(context);
|
||||
timelineAdapter.setColor(highlight, font);
|
||||
timelineAdapter.toggleImage(image);
|
||||
timelineList.setAdapter(timelineAdapter);
|
||||
}
|
||||
if (trendsAdapter == null) {
|
||||
trendsAdapter = new TrendAdapter(context);
|
||||
trendsAdapter.setColor(font);
|
||||
trendList.setAdapter(trendsAdapter);
|
||||
}
|
||||
if (mentionAdapter == null) {
|
||||
mentionAdapter = new TimelineAdapter(context);
|
||||
mentionAdapter.setColor(highlight, font);
|
||||
mentionAdapter.toggleImage(image);
|
||||
mentionList.setAdapter(mentionAdapter);
|
||||
}
|
||||
timelineAdapter.setColor(highlight, font);
|
||||
timelineAdapter.toggleImage(image);
|
||||
trendsAdapter.setColor(font);
|
||||
mentionAdapter.setColor(highlight, font);
|
||||
mentionAdapter.toggleImage(image);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,14 +1,10 @@
|
||||
package org.nuclearfog.twidda.backend;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
@ -31,57 +27,26 @@ public class UserLists extends AsyncTask<Long, Void, Boolean> {
|
||||
|
||||
private WeakReference<UserDetail> ui;
|
||||
private TwitterEngine mTwitter;
|
||||
private LayoutInflater inflater;
|
||||
private UserAdapter usrAdp;
|
||||
private Dialog popup;
|
||||
private String errorMessage = "E: Userlist, ";
|
||||
private int returnCode = 0;
|
||||
|
||||
/**
|
||||
* @see UserDetail
|
||||
*/
|
||||
|
||||
public UserLists(UserDetail context) {
|
||||
GlobalSettings settings = GlobalSettings.getInstance(context);
|
||||
boolean imageLoad = settings.loadImages();
|
||||
inflater = LayoutInflater.from(context);
|
||||
popup = new Dialog(context);
|
||||
|
||||
ui = new WeakReference<>(context);
|
||||
mTwitter = TwitterEngine.getInstance(context);
|
||||
RecyclerView userList = context.findViewById(R.id.userlist);
|
||||
|
||||
usrAdp = new UserAdapter(context);
|
||||
usrAdp.toggleImage(imageLoad);
|
||||
userList.setAdapter(usrAdp);
|
||||
}
|
||||
usrAdp = (UserAdapter) userList.getAdapter();
|
||||
|
||||
@Override
|
||||
@SuppressLint("InflateParams")
|
||||
protected void onPreExecute() {
|
||||
popup.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
popup.setCanceledOnTouchOutside(false);
|
||||
if (popup.getWindow() != null)
|
||||
popup.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
|
||||
View load = inflater.inflate(R.layout.item_load, null, false);
|
||||
View cancelButton = load.findViewById(R.id.kill_button);
|
||||
popup.setContentView(load);
|
||||
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
popup.dismiss();
|
||||
if (!isCancelled())
|
||||
cancel(true);
|
||||
}
|
||||
});
|
||||
popup.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
if (!isCancelled())
|
||||
cancel(true);
|
||||
}
|
||||
});
|
||||
popup.show();
|
||||
if (usrAdp == null) {
|
||||
usrAdp = new UserAdapter(context);
|
||||
usrAdp.toggleImage(imageLoad);
|
||||
userList.setAdapter(usrAdp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -108,27 +73,27 @@ public class UserLists extends AsyncTask<Long, Void, Boolean> {
|
||||
if (returnCode > 0 && returnCode != 420) {
|
||||
errorMessage += err.getMessage();
|
||||
}
|
||||
return false;
|
||||
} catch (Exception err) {
|
||||
Log.e("User List", err.getMessage());
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SuppressLint("InflateParams")
|
||||
protected void onPostExecute(Boolean success) {
|
||||
if (ui.get() == null)
|
||||
return;
|
||||
if (success) {
|
||||
usrAdp.notifyDataSetChanged();
|
||||
} else {
|
||||
if (ui.get() == null) return;
|
||||
|
||||
SwipeRefreshLayout refresh = ui.get().findViewById(R.id.user_refresh);
|
||||
refresh.setRefreshing(false);
|
||||
usrAdp.notifyDataSetChanged();
|
||||
|
||||
if (!success) {
|
||||
if (returnCode == 420)
|
||||
Toast.makeText(ui.get(), R.string.rate_limit_exceeded, Toast.LENGTH_SHORT).show();
|
||||
else if (returnCode > 0)
|
||||
Toast.makeText(ui.get(), errorMessage, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
popup.dismiss();
|
||||
}
|
||||
}
|
@ -77,7 +77,7 @@ public class MessagePopup extends AppCompatActivity implements View.OnClickListe
|
||||
if (v.getId() == R.id.dm_send) {
|
||||
String username = receiver.getText().toString();
|
||||
String message = text.getText().toString();
|
||||
if (!username.isEmpty() && (!message.isEmpty() || !mediaPath.isEmpty())) {
|
||||
if (!username.trim().isEmpty() && (!message.trim().isEmpty() || !mediaPath.isEmpty())) {
|
||||
MessageUpload upload = new MessageUpload(this);
|
||||
upload.execute(username, message, mediaPath);
|
||||
} else {
|
||||
|
@ -2,12 +2,12 @@ package org.nuclearfog.twidda.window;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.widget.SwipeRefreshLayout;
|
||||
import android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.nuclearfog.twidda.R;
|
||||
@ -17,7 +17,7 @@ import org.nuclearfog.twidda.database.GlobalSettings;
|
||||
import org.nuclearfog.twidda.viewadapter.UserAdapter;
|
||||
import org.nuclearfog.twidda.viewadapter.UserAdapter.OnItemClicked;
|
||||
|
||||
public class UserDetail extends AppCompatActivity implements OnItemClicked {
|
||||
public class UserDetail extends AppCompatActivity implements OnItemClicked, OnRefreshListener {
|
||||
|
||||
private RecyclerView userList;
|
||||
private UserLists uList;
|
||||
@ -25,6 +25,7 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked {
|
||||
private long userID = 0;
|
||||
private long tweetID = 0;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
@ -37,14 +38,17 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked {
|
||||
}
|
||||
setContentView(R.layout.userpage);
|
||||
|
||||
SwipeRefreshLayout refresh = findViewById(R.id.user_refresh);
|
||||
userList = findViewById(R.id.userlist);
|
||||
userList.setLayoutManager(new LinearLayoutManager(this));
|
||||
Toolbar toolbar = findViewById(R.id.user_toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
GlobalSettings settings = GlobalSettings.getInstance(this);
|
||||
int background = settings.getBackgroundColor();
|
||||
|
||||
userList.setBackgroundColor(background);
|
||||
GlobalSettings settings = GlobalSettings.getInstance(this);
|
||||
userList.setBackgroundColor(settings.getBackgroundColor());
|
||||
|
||||
refresh.setRefreshing(true);
|
||||
refresh.setOnRefreshListener(this);
|
||||
}
|
||||
|
||||
|
||||
@ -54,8 +58,7 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked {
|
||||
|
||||
if (uList == null) {
|
||||
uList = new UserLists(UserDetail.this);
|
||||
int titleId = 0;
|
||||
|
||||
int titleId;
|
||||
switch (mode) {
|
||||
case 0:
|
||||
titleId = R.string.following;
|
||||
@ -70,6 +73,7 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked {
|
||||
uList.execute(tweetID, UserLists.RETWEETER, -1L);
|
||||
break;
|
||||
case 3:
|
||||
default:
|
||||
titleId = R.string.favorite;
|
||||
uList.execute(tweetID, UserLists.FAVORISER, -1L);
|
||||
break;
|
||||
@ -82,24 +86,12 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
protected void onStop() {
|
||||
if (uList != null && !uList.isCancelled())
|
||||
uList.cancel(true);
|
||||
super.onPause();
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu m) {
|
||||
getMenuInflater().inflate(R.menu.user, m);
|
||||
return super.onCreateOptionsMenu(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == R.id.user_back)
|
||||
finish();
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(ViewGroup parent, int position) {
|
||||
@ -108,11 +100,24 @@ public class UserDetail extends AppCompatActivity implements OnItemClicked {
|
||||
TwitterUser user = userListAdapter.getData().get(position);
|
||||
long userID = user.userID;
|
||||
String username = user.screenname;
|
||||
|
||||
Intent intent = new Intent(this, UserProfile.class);
|
||||
intent.putExtra("userID", userID);
|
||||
intent.putExtra("username", username);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
uList = new UserLists(UserDetail.this);
|
||||
if (mode == 0)
|
||||
uList.execute(userID, UserLists.FOLLOWING, -1L);
|
||||
else if (mode == 1)
|
||||
uList.execute(userID, UserLists.FOLLOWERS, -1L);
|
||||
else if (mode == 2)
|
||||
uList.execute(tweetID, UserLists.RETWEETER, -1L);
|
||||
else
|
||||
uList.execute(tweetID, UserLists.FAVORISER, -1L);
|
||||
}
|
||||
}
|
@ -37,7 +37,6 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
private ProfileLoader mProfile;
|
||||
private SwipeRefreshLayout homeReload, favoriteReload;
|
||||
private RecyclerView homeList, favoriteList;
|
||||
|
||||
private TabHost mTab;
|
||||
private View lastTab;
|
||||
private boolean isFollowing, isBlocked, isMuted;
|
||||
@ -50,12 +49,13 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
@Override
|
||||
protected void onCreate(Bundle b) {
|
||||
super.onCreate(b);
|
||||
setContentView(R.layout.profilepage);
|
||||
|
||||
b = getIntent().getExtras();
|
||||
if (b != null) {
|
||||
userId = b.getLong("userID");
|
||||
username = b.getString("username");
|
||||
}
|
||||
setContentView(R.layout.profilepage);
|
||||
|
||||
Toolbar tool = findViewById(R.id.profile_toolbar);
|
||||
setSupportActionBar(tool);
|
||||
@ -98,6 +98,29 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
if (mProfile == null) {
|
||||
mProfile = new ProfileLoader(this);
|
||||
homeReload.setRefreshing(true);
|
||||
favoriteReload.setRefreshing(true);
|
||||
mProfile.execute(userId, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
if (mProfile != null && !mProfile.isCancelled()) {
|
||||
mProfile.cancel(true);
|
||||
homeReload.setRefreshing(false);
|
||||
favoriteReload.setRefreshing(false);
|
||||
}
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu m) {
|
||||
getMenuInflater().inflate(R.menu.profile, m);
|
||||
@ -181,29 +204,6 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mProfile == null) {
|
||||
mProfile = new ProfileLoader(this);
|
||||
homeReload.setRefreshing(true);
|
||||
favoriteReload.setRefreshing(true);
|
||||
mProfile.execute(userId, 0L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
if (mProfile != null && !mProfile.isCancelled()) {
|
||||
mProfile.cancel(true);
|
||||
homeReload.setRefreshing(false);
|
||||
favoriteReload.setRefreshing(false);
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (tabIndex == 0) {
|
||||
@ -235,6 +235,9 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
if (mProfile != null && !mProfile.isCancelled())
|
||||
mProfile.cancel(true);
|
||||
|
||||
switch (tabIndex) {
|
||||
case 0:
|
||||
mProfile = new ProfileLoader(this);
|
||||
@ -287,7 +290,6 @@ public class UserProfile extends AppCompatActivity implements OnClickListener,
|
||||
|
||||
private void animate() {
|
||||
final int ANIM_DUR = 300;
|
||||
|
||||
final int DIMENS = Animation.RELATIVE_TO_PARENT;
|
||||
final float LEFT = -1.0f;
|
||||
final float RIGHT = 1.0f;
|
||||
|
@ -1,9 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="20.0"
|
||||
android:viewportWidth="20.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M19,7v6c0,1.103 -0.896,2 -2,2H3v-3h13V8H5v2L1,6.5L5,3v2h12C18.104,5 19,5.896 19,7z" />
|
||||
</vector>
|
@ -9,9 +9,17 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/bar_wide" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/userlist"
|
||||
<android.support.v4.widget.SwipeRefreshLayout
|
||||
android:id="@+id/user_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/userlist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</android.support.v4.widget.SwipeRefreshLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/user_back"
|
||||
android:icon="@drawable/back"
|
||||
android:title="@string/back"
|
||||
app:showAsAction="always" />
|
||||
</menu>
|
Loading…
x
Reference in New Issue
Block a user