Skip to content

Commit

Permalink
updata
Browse files Browse the repository at this point in the history
还有UI需要调节一下
  • Loading branch information
didadida-r committed May 27, 2016
1 parent 56e42fc commit 47488ef
Show file tree
Hide file tree
Showing 50 changed files with 409 additions and 178 deletions.
17 changes: 0 additions & 17 deletions .gitattributes

This file was deleted.

2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ dependencies {
compile 'com.baoyz.pullrefreshlayout:library:1.2.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.yalantis:contextmenu:1.0.6'
compile 'jp.wasabeef:recyclerview-animators:1.3.0'
compile 'com.yalantis:phoenix:1.2.3'
}
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package="com.example.groovemax.splashimg">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
Expand All @@ -24,8 +25,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".WebActivity"/>
<activity android:name=".ImageDetailActivity"/>
<activity android:name=".WebActivity" />
<activity android:name=".ImageDetailActivity" />
<activity android:name=".FavoriteActivity" />

<service android:name=".DownLoadService" android:enabled="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public void onCreate() {

}


public static ThreadPoolManager getThreadPoolManager(){
return threadPoolManager;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
package com.example.groovemax.splashimg;

import android.content.Intent;
import android.database.Cursor;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import android.widget.RelativeLayout;

import com.dexafree.materialList.card.Card;
import com.dexafree.materialList.card.CardProvider;
import com.dexafree.materialList.listeners.OnDismissCallback;
import com.dexafree.materialList.listeners.RecyclerItemClickListener;
import com.dexafree.materialList.view.MaterialListView;
import com.example.groovemax.splashimg.MaterialList.MyCardProvider;
import com.example.groovemax.splashimg.SQLite.DataBaseHelper;



/**
*
*/
public class FavoriteActivity extends AppCompatActivity {
private static final String TAG = "debug";

private MaterialListView materialListView;
private Card card;
private RelativeLayout backgroundLayout;

private DataBaseHelper helper;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.favorite_layout);

initUi();

}

private void initUi(){

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitle("Favorite");
toolbar.setTitleTextColor(Color.BLACK);
toolbar.setNavigationIcon(R.mipmap.ic_arrow_back_black_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});

materialListView = (MaterialListView) findViewById(R.id.materialListView);
materialListView.addOnItemTouchListener(new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(Card card, int position) {
Log.v(TAG, "tag " + card.getTag().toString());
String[] data = (String[]) card.getTag();
Intent intent = new Intent();
intent.putExtra("user", data[0]);
intent.putExtra("largeImageURL", data[1]);
intent.putExtra("fullHDURL", data[2]);
intent.setClass(FavoriteActivity.this, ImageDetailActivity.class);
startActivity(intent);

}

@Override
public void onItemLongClick(Card card, int position) {
card.setDismissible(true);
materialListView.getAdapter().remove(card, true);
}
});

materialListView.setOnDismissCallback(new OnDismissCallback() {
@Override
public void onDismiss(Card card, int position) {
String[] data = (String[]) card.getTag();
helper.getReadableDatabase().delete("image_table", "imageUrl=?", new String[]{data[1]});
}
});

helper = new DataBaseHelper(getApplicationContext(), "FavoriteSQ", 1);
Cursor cursor = helper.getReadableDatabase().rawQuery("select * from image_table", null);
while(cursor.moveToNext()){
card = new Card.Builder(this)
.setTag(new String[]{cursor.getString(1), cursor.getString(2), cursor.getString(3)})
.withProvider(new CardProvider())
.setLayout(R.layout.card_favorite_layout)
.setDrawable(cursor.getString(2))
.endConfig()
.build();
materialListView.getAdapter().add(card);
}
cursor.close();
backgroundLayout = (RelativeLayout) findViewById(R.id.backgroundLayout);

if(getSharedPreferences("theme", MODE_PRIVATE).getBoolean("themeColor", false)){
backgroundLayout.setBackgroundColor(getResources().getColor(R.color.themeColor));
toolbar.setBackgroundColor(getResources().getColor(R.color.themeColor));
}

}

@Override
protected void onDestroy() {
super.onDestroy();
if(helper != null)
helper.close();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.groovemax.splashimg;

import android.database.Cursor;
import android.os.Environment;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.FragmentManager;
Expand All @@ -25,6 +26,7 @@
import android.widget.Toast;


import com.example.groovemax.splashimg.SQLite.DataBaseHelper;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
import com.yalantis.contextmenu.lib.ContextMenuDialogFragment;
Expand All @@ -39,7 +41,7 @@


/**
* Created by 60546 on 5/11/2016.
*
*/
public class ImageDetailActivity extends AppCompatActivity implements OnMenuItemClickListener {

Expand All @@ -51,6 +53,7 @@ public class ImageDetailActivity extends AppCompatActivity implements OnMenuItem
private FragmentManager fragmentManager;
private Bundle bundle;
private Intent serviceIntent;
private DataBaseHelper helper;

private String imageUrl; //the imageUrl to display (*,1280)
private String imageUrlHD; //the imageUrl to display (*,1920)
Expand Down Expand Up @@ -99,11 +102,15 @@ public void onClick(View v) {
MenuObject downloadHD = new MenuObject("download HD image");
downloadHD.setResource(R.mipmap.ic_arrow_back_white_24dp);

MenuObject addFavorite = new MenuObject("add Favorites");
addFavorite.setResource(R.mipmap.ic_arrow_back_white_24dp);

List<MenuObject> menuObjects = new ArrayList<>();
menuObjects.add(close);
menuObjects.add(setWall);
menuObjects.add(download);
menuObjects.add(downloadHD);
menuObjects.add(addFavorite);

MenuParams menuParams = new MenuParams();
menuParams.setActionBarSize(150);
Expand Down Expand Up @@ -161,30 +168,26 @@ public void onMenuItemClick(View clickedView, int position) {
serviceIntent.putExtras(bundle);
startService(serviceIntent);
break;
default:
break;
}
}
case 4:
/** Add Favorite Image */
helper = new DataBaseHelper(getApplicationContext(), "FavoriteSQ", 1);
Cursor cursor = helper.getReadableDatabase().rawQuery("select * from image_table where "
+ "imageUrl=?", new String[]{imageUrl});
if(cursor.moveToFirst()){
Toast.makeText(this, "already added in Favorites", Toast.LENGTH_SHORT).show();
cursor.close();
return;
}
cursor.close();

helper.getReadableDatabase().execSQL("insert into image_table values(NULL, ?, ?, ?)",
new String[]{title, imageUrl, imageUrlHD});
helper.close();

/*
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_image_detail, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.context_menu:
//fragmentManager = getSupportFragmentManager();
//mMenuDialogFragment.show(fragmentManager, "ContextMenuDialogFragment");
default:
break;
}
return super.onOptionsItemSelected(item);
}
*/

/*
* Do not use anonymous callback
Expand Down
Loading

0 comments on commit 47488ef

Please sign in to comment.